#include<stdio.h>

#define NUM1(x,y) x+y
#define NUM2(x,y) x-y
#define NUM3(x,y) x*y
#define NUM4(x,y) (float)x/y

void homework1()
{
    printf("作业1\n");
    printf("char          的字节占用为：%ld\n",sizeof(char));
    printf("short int     的字节占用为：%ld\n",sizeof(short int));
    printf("int           的字节占用为：%ld\n",sizeof(int));
    printf("long int      的字节占用为：%ld\n",sizeof(long int));
    printf("long long int 的字节占用为：%ld\n",sizeof(long long int));
    printf("float         的字节占用为：%ld\n",sizeof(float));
    printf("double        的字节占用为：%ld\n",sizeof(double));
    printf("long double   的字节占用为：%ld\n",sizeof(long double));
}

void homework2(int a,int b)
{
    printf("\n作业2\n");
    int   add = NUM1(20,30);
    int   sub = NUM2(20,30);
    int   ceg = NUM3(20,30);
    float dif = NUM4(20,30);

    printf("add=%d  \n",add);
    printf("sub=%d  \n",sub);
    printf("ceg=%d  \n",ceg);
    printf("dif=%.3f\n",dif);
}

void homework3(float mm,float mil)
{
    printf("\n作业3");
    while(1){
        int choose;
        printf("\n若要mm->mil输入2\n若要mil->mm输入1\n若退出请输入0\n");
        scanf("%d",&choose);
    switch(choose){
            case 2:{
                printf("请输入mm:");
                scanf("%f",&mm);
                mil = 39.3701*mm;
                printf("%.0fmm=%.4fmil\n",mm,mil);
                    break;
            }
            case 1:{
                printf("请输入mil:");
                scanf("%f",&mil);
                mm = 0.0254*mil;
                printf("%.0fmil=%.4fmm\n",mil,mm);
                    break;
            } 
            case 0:
                return;
        }
    }
}

int main()
{
    int x,y;
    float a,b;
    homework1();
    homework2(x,y);
    homework3(a,b);
}